/*
 * get.java
 *
 * By Gary Wong, 2005.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of Version 2 of the GNU General Public 
 * License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 */

package sxe.core.temp;

import snobject.snObject;
import snobject.snObjectArgList;
import step.EvaluationFailure;
import step.FunctionWrapper;
import sxe.sensors.GenericSensor;
import sxe.sensors.SensorDetector;
import sxe.sensors.TempSensor;

public class get extends FunctionWrapper {	
	
    public snObject Call(snObjectArgList arg) throws EvaluationFailure {
	String id = arg.popString().getString();
	GenericSensor sensor = SensorDetector.GetDevice( id, 
							 GenericSensor.TYPE_TEMPERATURE );

	if( sensor == null ) {
	    System.err.println( "No temperature sensor " + id );
	    throw new EvaluationFailure( this.expnode,
					 "Couldn't get temperature sensor " +
					 id );
	}

	TempSensor tempSensor = (TempSensor) sensor;

	return tempSensor.getData( null );
    }
}
